<!-- 新增/编辑场景模态框 -->
<div class="modal fade" id="addEditModal" tabindex="-1" aria-labelledby="addEditModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-xl modal-fullscreen-lg-down">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addEditModalLabel">新增场景</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="add-edit-form">
                    <div class="row mb-3">
                        <div class="col-md-8">
                            <label for="scene-name" class="form-label">场景名称</label>
                            <input type="text" class="form-control" id="scene-name" required>
                        </div>
                        <div class="col-md-4">
                            <label for="scene-tags" class="form-label">标签</label>
                            <input type="text" class="form-control" id="scene-tags" placeholder="用逗号分隔">
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="scene-description" class="form-label">描述</label>
                        <textarea class="form-control" id="scene-description" rows="2"></textarea>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-header">
                                    <h5 class="mb-0">API列表</h5>
                                    <div class="input-group mt-2">
                                        <input type="text" id="api-search" class="form-control" placeholder="搜索API...">
                                        <button class="btn btn-outline-secondary" type="button" id="api-search-btn">
                                            <i class="bi bi-search"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <div id="api-list" class="list-group api-list">
                                        <!-- API列表将通过JavaScript动态加载 -->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-8">
                            <div class="card">
                                <div class="card-header d-flex justify-content-between align-items-center">
                                    <h5 class="mb-0">场景步骤</h5>
                                    <div>
                                        <button type="button" class="btn btn-sm btn-primary" id="add-script-btn">
                                            <i class="bi bi-code-slash"></i> 添加脚本
                                        </button>
                                        <button type="button" class="btn btn-sm btn-warning" id="add-condition-btn">
                                            <i class="bi bi-diagram-3"></i> 添加条件
                                        </button>
                                        <button type="button" class="btn btn-sm btn-info" id="add-loop-btn">
                                            <i class="bi bi-arrow-repeat"></i> 添加循环
                                        </button>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <div id="scene-steps" class="scene-steps">
                                        <div class="alert alert-info">
                                            <i class="bi bi-info-circle"></i> 点击左侧API 旁边的 + 号添加API到此处，或使用上方按钮添加脚本、条件或循环步骤
                                        </div>
                                        <div id="steps-container" class="steps-container">
                                            <!-- 场景步骤将通过JavaScript动态加载 -->
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <button type="submit" form="add-edit-form" class="btn btn-primary" id="save-scene-btn">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- 脚本步骤模态框 -->
{% include 'scene/script_modal.html' %}

<!-- 条件步骤模态框 -->
{% include 'scene/condition_modal.html' %}

<!-- 循环步骤模态框 -->
{% include 'scene/loop_modal.html' %}